#!/bin/bash

# 定义实体类名称数组
entities=(
    "Admin"
    "Comment"
    "Follow"
    "Illustration"
    "IllustrationTag"
    "IllustrationCollection"
    "LikeIllustration"
    "LikeTag"
    "Message"
    "Order"
    "Product"
    "ProductImg"
    "Report"
    "ReportStatusLog"
    "Shop"
    "SubLevel"
    "SubLevelPricing"
    "Tag"
)

# 定义包路径
base_package="com/isoft/illustrationsdraw"
service_path="${base_package}/service"
impl_path="${service_path}/impl"

# 确保目录存在
mkdir -p "$service_path"
mkdir -p "$impl_path"

# 遍历实体类名称数组并生成服务接口和实现类
for entity in "${entities[@]}"; do
    # 服务接口文件
    service_file="${service_path}/${entity}Service.java"
    cat > "$service_file" << EOF
package com.isoft.illustrationsdraw.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.isoft.illustrationsdraw.entity.${entity};

public interface ${entity}Service extends IService<${entity}> {

}
EOF
    echo "Created: $service_file"

    # 服务实现类文件
    impl_file="${impl_path}/${entity}ServiceImpl.java"
    cat > "$impl_file" << EOF
package com.isoft.illustrationsdraw.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.isoft.illustrationsdraw.entity.${entity};
import com.isoft.illustrationsdraw.mapper.${entity}Mapper;
import com.isoft.illustrationsdraw.service.${entity}Service;
import org.springframework.stereotype.Service;

@Service
public class ${entity}ServiceImpl extends ServiceImpl<${entity}Mapper, ${entity}> implements ${entity}Service {

}
EOF
    echo "Created: $impl_file"
done

echo "All service interfaces and implementation classes have been created successfully!"
